import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
let contexts = require.context('.', false, /(?!.*index).js$/)
let routes = []
contexts.keys().forEach(component => {
  if (contexts(component).default) {
    routes.push(contexts(component).default)
  }
})
let main = {
  name: 'Main',
  pageName: '入口',
  navHide: true,
  path: '/',
  redirect: '/home'
}
let notFound = {
  name: 'notFound',
  pageName: '404页面',
  navHide: true,
  path: '*',
  component: () => import('@/components/notFound.vue')
}
let allRoutes = [main, ...routes, notFound]
let router = new Router({
  routes: allRoutes
})
export default router